package com.class5.springboot.frame.repo.dto;

import java.io.Serializable;
import java.util.List;

/**
 * 分页查询的结果
 * @author Administrator
 *
 */
public class PageData implements Serializable {
    /**
     *
     */
    private static final long serialVersionUID = 1L;
    //当前页数据
    @SuppressWarnings("rawtypes")
    private List records;
    //页码
    private int page;

    //每页大小
    private int size;
    //记录总数
    private int total;
    public PageData() {

    }
    @SuppressWarnings("rawtypes")
    public PageData(List data, int page, int size, int total) {
        super();
        this.records = data;
        this.page = page;
        this.size = size;
        this.total = total;
    }

    @SuppressWarnings("unchecked")
    public void convert(RecordConvert convert){
        if(this.records != null){
            for(int i=0; i<this.records.size(); i++){
                Object rec = convert.convert(this.records.get(i));
                if(rec == null){
                    this.records.remove(i);
                    i--;
                }else{
                    this.records.set(i, rec);
                }
            }
        }
    }
    @SuppressWarnings("rawtypes")
    public List getRecords() {
        return records;
    }
    @SuppressWarnings("rawtypes")
    public PageData setRecords(List data) {
        this.records = data;
        return this;
    }
    public int getPage() {
        return page;
    }
    public PageData setPage(int page) {
        this.page = page;
        return this;
    }
    public int getSize() {
        return size;
    }
    public PageData setSize(int size) {
        this.size = size;
        return this;
    }
    public int getTotal() {
        return total;
    }
    public PageData setTotal(int total) {
        this.total = total;
        return this;
    }
}